/**
 * slim accordion plugin
 * @author Levin
 * @version 1.0
 */
;(function($) {
    // Private functions.
    var p = {};
	p.M=function(dom,opts){
		this.opts=opts;
		dom=$(dom);
		this.ui={
			$dom:dom,
			$items:dom.find(opts.cssBody),
			$curBody:null
		};
		this.init();
	};
	p.M.prototype={
		init:function(){
			var me=this;
			me.ui.$dom.find(me.opts.cssTrigger).mouseenter(function(){
				var $i=$(this),
					$bd=me._getCurBody($i);
				if($bd.is(":visible")) return;

				if(me.ui.$curBody){
					me.ui.$curBody.hide();
				};
				me.ui.$curBody=$bd.stop(true,true).fadeIn(me.opts.duration);
			}).eq(0).trigger('mouseenter');
		},
		_getCurBody:function($curTrigger){
			if(this.opts.getCurBody){
				return this.opts.getCurBody.call(this,$curTrigger);
			};

			return $curTrigger.find(this.opts.cssBody);
		}
	};
    //main plugin body
    $.fn.slimAccordion = function(opts) {
        // Set the options.
        opts = $.extend({}, $.fn.slimAccordion.defaults, opts||{});
        // Go through the matched elements and return the jQuery object.
        return this.each(function() {
			new p.M(this,opts);
        });
    };
    // Public defaults.
    $.fn.slimAccordion.defaults = {
		duration:'slow',
		cssTrigger:'a',
		cssBody:'.wdg-acd-bd',
		getCurBody:null
    };
})(jQuery);  